package truef.customer.web.spring.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.google.gson.Gson;

import edu.zut.cs.software.base.web.spring.controller.GenericController;
import truef.customer.domain.Coupon;
import truef.favoriteshop.domain.Favorite;
import truef.service.customer.service.CouponManager;

@Controller
//拦截含有commodity的url并处理
@RequestMapping("/coupon")//1.
public class CouponController extends GenericController<Coupon, Long, CouponManager>{

	CouponManager couponManager;
	/*
	 * 部署成功后，在浏览器中输入url
	 * http://localhost:8080/universalStore-web/${1.}/${2.value值}
	 * 例子:http://localhost:8080/universalStore-web/Coupon/index.html
	*/
	@CrossOrigin(origins = "*")
	@ResponseBody
	@RequestMapping(value = "/findall.json",produces = "text/plain;charset=utf-8")
	public String findall() {
		List<Coupon> CommentList = couponManager.findAll();
		Gson gson = new Gson();
		String s = gson.toJson(CommentList);
		return s;
	}

	@Autowired
	public void setCouponManager(CouponManager couponManager) {
		this.couponManager = couponManager;
		this.manager = this.couponManager;
	}

	
}
